package com.example.demo.controller;

import com.example.demo.Grade.Grades;
import com.example.demo.Grade.GradesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/grades")
public class SelectGradesController {

    @Autowired
    private GradesService gradesService;



    @GetMapping("/{cname}")
    public String getgrades(@RequestParam String cname ,Model model) {
        Grades grades=gradesService.getgrades(cname);
        model.addAttribute("cname", grades );
        return "grades";

    }

    @GetMapping
    public String getallgrades(Model model) {
        List<Grades> gradesList=gradesService.getAllgrades();
        model.addAttribute(gradesList);
        return "grades";

    }


}
